package com.itheima;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * @ProjectName: shixun DaErXia
 * @Titile: CollectionDemo
 * @Author: 雨
 * @Description: TODO
 */
public class CollectionDemo {
    public static void main(String[] args) {
        List<String> list=new LinkedList<>() ;
        Collections.addAll(list,"zhangsan","lisi","wangwu","zhaoliu");
        list.forEach(System.out::println);
        System.out.println("-------------");
        Collections.shuffle(list);
        list.forEach(System.out::println);

    }
    public static void test1(){
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);
        Collections.sort(list);
        list.forEach(System.out::println);
        Collections.sort(list, (o1, o2) -> {
            //按照倒序排
            return 02-01;
        });
        System.out.println("---------------");
        list.forEach(System.out::println);
        //让学生Student实现comparable接口，这样也能给学生排序
        System.out.println("---------------");
        List<Student> list1 = new ArrayList<>();
        list1.add(new Student("zhaoliu",22));
        list1.add(new Student("zhangsan",20));
        list1.add(new Student("wangwu",18));
        Collections.sort(list1);
        list.forEach(System.out::println);

        List<Integer> synchronizedList=Collections.synchronizedList(list);
    }
}
